package com.ydd.mapper;

import com.github.pagehelper.Page;
import com.ydd.dto.YddAdvimgPageDTO;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ydd.entity.YddAdvimg;
import com.ydd.vo.YddAdvimgVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import com.ydd.entity.YddAdvpos;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface YddAdvimgMapper extends BaseMapper<YddAdvimg> {

    @Select("select COUNT(*) from ydd_advimg")
    Integer count();

    @Select("select * from ydd_advimg where advimgpos=#{id}")
    List<YddAdvimg> getAdvimgposSum(Integer id);

    Page<YddAdvimgVO> selectALL(YddAdvimgPageDTO yddAdvimgPageDTO);

    @Select("select * from ydd_advimg where id = #{id};")
    YddAdvimg getInfoById(Integer id);

    @Delete("delete from ydd_advimg where id = #{id};")
    void deleteById(Integer id);

    @Insert("insert into ydd_advimg " +
            "values (null, #{advimgpos}, #{advimgsrc}, #{advimgdesc}, " +
            "#{advimglink}, #{defaultData});")
    void add(YddAdvimg yddAdvimg);
}
